﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Communication
{
    /// <summary>
    /// 试剂控制
    /// </summary>
    public class SampleControl:ControlBase
    {
        string mYR = "YR",//复位
            mYS = "YS",//送样
            mYB = "YB";//换样品
        string mSM = "SM",//扫描条形码
            mYZ = "YZ",//是否有试管
            mSV = "SV";//设置灵敏度
        
        public bool IsTube
        {
            get;
            set;
        }
        string _barcode = "";
        /// <summary>
        /// 当前扫描到的
        /// </summary>
        public string Barcode
        {
            get
            {
                return _barcode;
            }
            set
            {
                _barcode = value;
            }
        }
        public SampleControl()
        {
            mCanId = Can.SAMPLE_ID;
            mSubCanId = Can.Barcode_ID;
            mSCmd = new Dictionary<int, string>();
            mSCmd.Add(0, mYR);
            mSCmd.Add(1, mYS);
            mSCmd.Add(2, mYB);
        }
        /// <summary>
        /// 复位
        /// </summary>
        /// <returns></returns>
        public int Reset()
        {
            SendCmd(0,mYR);
            mStatus = -100;
            return 0;
        }
        /// <summary>
        /// 定位 发一次走一个，发十次走完
        /// </summary>
        /// <returns></returns>
        public int Position()
        {
            SendCmd(1,mYS);
            mStatus = -1;
            return 1;
        }
        /// <summary>
        /// 换样品架
        /// </summary>
        /// <returns></returns>
        public int ChangeShelf()
        {
            SendCmd(2,mYB);
            mStatus = -2;
            return 2;
        }
        /// <summary>
        /// 获得试管条形码
        /// </summary>
        /// <returns>3</returns>
        public int GetBarcode()
        {
            Can.SendCan(Can.Barcode_ID,mSM+Can.strEnd);

            mStatus = -3;
            return 3;
        }
        /// <summary>
        /// 判断是否有试管
        /// </summary>
        /// <returns>4</returns>
        public int CheckTube()
        {
            Can.SendCan(Can.Barcode_ID, mYZ + Can.strEnd);
            mStatus = -4;
            return 4;
        }
        /// <summary>
        /// 设置灵敏度
        /// </summary>
        /// <returns></returns>
        public int SV(int count)
        {
            Can.SendCan(Can.Barcode_ID, mSV + count + Can.strEnd);
            mStatus = 5;
            return 5;
        }

    }
}
